package com.hellohoper.cloud.starter.redis;

import com.hellohoper.assembly.common.utils.serialize.hessian.Hessian2Serializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * Created by hk on 17/8/19.
 */
public class HsRedisSerializer<T> implements RedisSerializer<T> {


    @Override
    public byte[] serialize(T t) throws SerializationException {
        return Hessian2Serializer.getInstance().serializeByte(t);
    }

    @Override
    public T deserialize(byte[] bytes) throws SerializationException {
        return (T) Hessian2Serializer.getInstance().deserializeByte(bytes);
    }
}
